\setchapterpreamble[u]{\margintoc}
\chapter{Margin stuff}

侧记是所有1.5列布局书籍的一个显著特征。事实上，宽边意味着一些材料可以在那里展示。我们对所有的东西都使用边距:旁注、边注、小目录、引文，为什么不呢?，特殊的盒子和环境。

\section{Sidenotes}

Sidenotes are like footnotes, except that they go in the margin, where 
they are more readable. To insert a sidenote, just use the command 
\Command{sidenote\{Text of the note\}}. You can specify a 
mark\sidenote[O]{This sidenote has a special mark, a big O!} with \\ 
\Command{sidenote[mark]\{Text\}}, but you can also specify an offset, 
which moves the sidenote upwards or downwards, so that the full syntax is:

\begin{lstlisting}[style=kaolstplain]
\sidenote[offset][mark]{Text}
\end{lstlisting}

If you use an offset, you always have to add the 
brackets for the mark, but they can be empty.\sidenote{If you want to 
know more about the usage of the \Command{sidenote} command, read the 
documentation of the \Package{snotez} package.} The format of the actual 
sidenote can be changed with the command \Command{setsidenotes}, which 
allows you to modify, for instance, the format of the markers and the 
separator between the marker and the text of the sidenote.

There was an alternative package, \Package{sidenotes}, which we could 
have used. In the end we went for \Package{snotez} because it was the 
one used in Ken Ohori's thesis, which inspired this class. The features 
are very similar, but one additional thing offered by \Package{snotez} 
is that the offset can be specified as a multiple of 
\Command{baselineskip}. For example, if you want to enter a sidenote 
with the normal mark and move it upwards one line, type:

\begin{lstlisting}[style=kaolstplain]
\sidenote[*-1][]{Text of the sidenote.}
\end{lstlisting}

Sidenotes are handled through the \Package{snotez} package, which in 
turn relies on the \Package{marginnote} package.

\section{Marginnotes}

This command is very similar to the previous one. You can create a 
marginnote with \Command{marginnote[offset]\{Text\}}, where the offset 
argument can be left out, or it can be a multiple of 
\Command{baselineskip},\marginnote[-1cm]{While the command for margin 
notes comes from the \Package{marginnote} package, it has been redefined 
in order to change the position of the optional offset argument, which 
now precedes the text of the note, whereas in the original version it 
was at the end. We have also added the possibility to use a multiple of 
\Command{baselineskip} as offset. These things were made only to make 
everything more consistent, so that you have to remember less things!} 
\eg

\begin{lstlisting}[style=kaolstplain]
\marginnote[-12pt]{Text} or \marginnote[*-3]{Text}
\end{lstlisting}

\begin{kaobox}[frametitle=To Do]
A small thing that needs to be done is to renew the \Command{sidenote} 
command so that it takes only one optional argument, the offset. The 
special mark argument can go somewhere else. In other words, we want the 
syntax of \Command{sidenote} to resemble that of \Command{marginnote}.
\end{kaobox}

We load the packages \Package{marginnote}, \Package{marginfix} and 
\Package{placeins}. Since \Package{snotez} uses \Package{marginnote}, 
what we said for marginnotes is also valid for sidenotes. Side- and 
margin- notes are shifted slightly upwards 
(\Command{renewcommand\{\textbackslash marginnotevadjust\}\{3pt\}}) in 
order to allineate them to the bottom of the line of text where the note 
is issued.

\section{Footnotes}

Even though they are not displayed in the margin, we will discuss about 
footnotes here, since sidenotes are mainly intended to be a replacement 
of them. Footnotes force the reader to constantly move from one area of 
the page to the other. Arguably, marginnotes solve this issue, so you 
should not use footnotes. Nevertheless, for completeness, we have left 
the standard command \Command{footnote}, just in case you want to put a 
footnote once in a while.\footnote{And this is how they look like. 
Notice that in the PDF file there is a back reference to the text; 
pretty cool, uh?}

\section{Margintoc}

Since we are talking about margins, we introduce here the 
\Command{margintoc} command, which allows one to put small table of 
contents in the margin. Like other commands we have discussed, 
\Command{margintoc} accepts a parameter for the vertical offset, like 
so: \Command{margintoc[offset]}.

The command can be used in any point of the document, but we think it 
makes sense to use it just at the beginning of chapters or parts. In 
this document I make use of a \KOMAScript\xspace feature and put it in 
the chapter preamble, with the following code:

\marginnote{The font used in the margintoc is the same as the one for 
	the chapter entries in the main table of contents at the beginning 
	of the document.}

\begin{lstlisting}[style=kaolstplain]
\setchapterpreamble[u]{\margintoc}
\chapter{Chapter title}
\end{lstlisting}

Not only textual stuff can be displayed in the margin, but also figures. 
Those will be the focus of the next chapter.
